{%  extends "model/adminbase.html" %}
{% block title %} 所有公告 {% endblock %}
<!--JS代码-->
{% block script %}
<script>
    $(function () {
        {% for item in notices %}
            {% for notice in item.notices %}
            $("#delete{{ notice.id }}").click(function () {
                $.ajax({
                    url: "/cancelNotice/",
                    way: 'GET',
                    data: {ID:{{notice.id}}},
                    success: function (rep) {
                        if (rep === 'ok'){

                            alert("撤销成功")
                            $("#notice{{ notice.id }}").hide({duration:500});
                        }else{
                            alert("撤销失败")
                        }
                    },
                    error: function () {
                        alert("撤销失败")
                    }
                })
            })
                {% endfor %}
        {% endfor %}
    })
</script>
{% endblock %}
<!--css代码-->


{% block content %}
    <div class="row">
          <div class="col-md-12">
            <!-- The time line -->
            <div class="timeline">
              {% for item in notices %}
                  <!--年加月份-->
              <div class="time-label">
                <span class="bg-red">{{ item.YM }}</span>
              </div>
              <!--每个项-->
                  {% for notice in item.notices %}
              <div id="notice{{ notice.id }}">
                <i class="fas fa-bullhorn bg-blue"></i>
                <div class="timeline-item">
                  <span class="time"><i class="fas fa-clock"></i> {{ notice.NTime }}</span>
                  <h3 class="timeline-header">阅读次数： {{ notice.ReadTimes }}</h3>

                  <div class="timeline-body">
                        <h4 class="font-weight-bold">{{ notice.Title }}</h4>
                  </div>
                  <div class="timeline-footer">
                    <a class="btn btn-primary btn-sm" href="{% url 'admin_noticepage' notice.id %}">阅读</a>
                       <button class="btn btn-danger btn-sm" id="delete{{ notice.id }}">撤销</button>


                  </div>
                </div>
              </div>
                      {% endfor %}
             {% endfor %}
              <div>
                <i class="fas fa-clock bg-gray"></i>
              </div>
            </div>
          </div>
          <!-- /.col -->
        </div>
{% endblock %}
